﻿@model PageList<Model.Models.Product>

@{
    ViewData["Title"] = "商品列表";
}

<h2>商品列表</h2>

<p>
    <a asp-action="Create">新增一个商品(方法实现没页面)</a>
    <a> | </a>
    <a asp-action="NewProduct"> 初始化商品数据（30条）</a>
</p>
<form asp-action="Index" method="get">
    <div class="form-actions no-color">
        <p>
            搜索: <input type="text" name="SearchString" value="@ViewData["CurrentFilter"]" />
            <input type="submit" value="提交" class="btn btn-default" />
        </p>
    </div>
</form>
<table class="table">
    <thead>
        <tr>
            <th>
                编号
            </th>
            <th>
                名称
            </th>
            <th>
                <a asp-action="Index" asp-route-sortOrder="@ViewData["PriceSortOrder"]"asp-route-currentFilter="@ViewData["CurrentFilter"]">  价格</a>
            </th>
            <th>
                <a asp-action="Index" asp-route-sortOrder="@ViewData["TimeSortOrder"]"asp-route-currentFilter="@ViewData["CurrentFilter"]"> 时间</a>
            </th>
            <th></th>
        </tr>
    </thead>
    <tbody>
        @foreach (var item in Model)
        {
            <tr>
                <td>
                    @Html.DisplayFor(modelItem => item.Id)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.Name)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.Price)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.Createtime)
                </td>
                <td>
                    <a asp-action="Edit" asp-route-id="@item.Id">编辑（方法实现没页面）</a>
                    <a asp-action="Delete" asp-route-id="@item.Id">删除</a>
                </td>
            </tr>
        }
    </tbody>
</table>
@{
    var prevDisabled = !Model.HasPreviousPage ? "disabled" : "";
    var nextDisabled = !Model.HasNextPage ? "disabled" : "";
}

<a asp-action="Index"
   asp-route-sortOrder="@ViewData["SortOrder"]"
   asp-route-page="@(Model.PageIndex - 1)"
   asp-route-currentFilter="@ViewData["CurrentFilter"]"
   class="btn btn-default @prevDisabled btn">
    上一页
</a>
<a asp-action="Index"
   asp-route-sortOrder="@ViewData["SortOrder"]"
   asp-route-page="@(Model.PageIndex + 1)"
   asp-route-currentFilter="@ViewData["CurrentFilter"]"
   class="btn btn-default @nextDisabled btn">
    下一页
</a>